package com.mazaiting.dtp.email;

import com.dtp.common.ApplicationContextHolder;
import com.dtp.common.dto.NotifyPlatform;
import com.dtp.common.em.NotifyPlatformEnum;
import com.dtp.core.notify.base.Notifier;
import com.mazaiting.dtp.listeners.event.EmailEvent;
import lombok.extern.slf4j.Slf4j;

/**
 * 邮件通知
 *
 * @author mazaiting
 * @create_time 2022/10/5 18:40
 */
@Slf4j
public class EmailNotifier implements Notifier {

    @Override
    public String platform() {
        return NotifyPlatformEnum.EMAIL.name().toLowerCase();
    }

    @Override
    public void send(NotifyPlatform platform, String content) {
        log.info(platform.toString() + ", content: {}", content);
        // 发布事件
        ApplicationContextHolder.publishEvent(new EmailEvent(platform, content));
    }
}
